package com.glory.gloryquickui.model

import com.glory.gloryquickui.base.BaseRepository
import com.glory.gloryquickui.entity.VersionEntity
import com.glory.gloryquickui.utils.InitUtils
import rxhttp.toClass
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse2

/**
 * @author HX
 * @date 2021/4/20
 * @desc 网络请求逻辑
 */
class LoginRepository : BaseRepository() {
//    var LoginUrl: String = InitUtils.BaseUrl + "/basis_service/"
    suspend fun login(userName: String, password: String): String {
        return RxHttp.postJson(InitUtils.BaseUrl + "/basis_service/user/login")
            .add("username", userName)
            .add("password", password)
            .toResponse2<String>()
            .await()
    }

    /**
     * 获取版本更新信息
     */
    suspend fun version(): VersionEntity {
        return RxHttp.get(InitUtils.FileUrl)
            .toClass<VersionEntity>()
            .await()
    }
}